﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ImageSearch;

namespace TienTeTuong
{
    public class DataProvider
    {
        public static String CreateConnectString()
        {
            String m_ConnectionString = null;
            try
            {
                string sPath = HttpContext.Current.Server.MapPath("~") + "\\Config\\config.ini";
                var ini = new IniFile(sPath);
                String strDatabase = ini.IniReadValue("User", "Database", "TienTeTuong");
                String strDataSource = ini.IniReadValue("User", "DataSource", "127.0.0.1");
                String strUserId = ini.IniReadValue("User", "UserId", "root");
                String strPassword = ini.IniReadValue("User", "Password", "");
                string lpszConnection = "Database=" + strDatabase
                                        + ";Data Source=" + strDataSource
                                        + ";User Id=" + strUserId
                                        + ";Password=" + strPassword
                                        + ";pooling=false;CHARSET=utf8";
                //lpszConnection += ";Min Pool Size = 1;Max Pool Size=150";
                m_ConnectionString = lpszConnection;
                //pszConnection = "Server=localhost;Database=tientetuong;UserID=root;Password=;Persist Security Info=True; charset = utf8;";
                return lpszConnection;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}